package js;

import java.util.Scanner;

public class q反异或01串 {
    public static void main(String[] args) {
        //【输入格式】
        //输入一行包含一个01串表示给定的T。
        Scanner scan = new Scanner(System.in);
        String T = scan.nextLine();
        int ans = 0;

        // 找到子串
        String sub1 = findSub(T);
        // 统计sub1的0和1数量
        int zeroNum1 = 0;
        int oneNum1= 0;
        for(int i = 0; i < sub1.length(); i++){
            if(sub1.charAt(i) == '0'){
                zeroNum1++;
            }else{
                oneNum1++;
            }
        }
        String sub2 = findSub2(sub1);

        // 统计sub2的0和1数量
        int zeroNum2 = 0;
        int oneNum2 = 0;
        for(int i = 0; i < sub2.length(); i++){
            if(sub2.charAt(i) == '0'){
                zeroNum2++;
            }else{
                oneNum2++;
            }
        }
        if(sub2.length()%2==0){
            ans = oneNum2/2+oneNum1-oneNum2;
        }else {
            // 奇长度比较复杂了，暂时不去考虑了，直接碰运气
            ans = oneNum2/2+oneNum1-oneNum2;
        }


        System.out.println(ans);
    }
    static String findSub(String str){
        String ans = str;
        //去除两端的连续的0，留下子串
        while(true){
            if(ans.charAt(0) == '0'){
                ans = ans.substring(1);
            }else if(ans.charAt(ans.length() - 1) == '0'){
                ans = ans.substring(0, ans.length() - 1);
            }else{
                break;
            }
        }
        return ans;

    }

    static String findSub2(String str){
        if (str == null || str.length() == 0) {
            return "";
        }

        int start = 0;
        int end = 0;

        for (int i = 0; i < str.length(); i++) {
            int len1 = expandAroundCenter(str, i, i);
            int len2 = expandAroundCenter(str, i, i + 1);
            int len = Math.max(len1, len2);

            if (len > end - start) {
                start = i - (len - 1) / 2;
                end = i + len / 2;
            }
        }

        return str.substring(start, end + 1);
    }

    static int expandAroundCenter(String str, int left, int right) {
        while (left >= 0 && right < str.length() && str.charAt(left) == str.charAt(right)) {
            left--;
            right++;
        }

        return right - left - 1;
    }

    static String fanyihuo(String str){
        // 先倒转String
        char[] arr = str.toCharArray();
        int len = arr.length;
        for(int i = 0; i < len / 2; i++){
            char temp = arr[i];
            arr[i] = arr[len - 1 - i];
            arr[len - 1 - i] = temp;
        }
        String rev = String.valueOf(arr);
        // 再用rev 与 原str 进行按位异或计算
        String ans = "";
        for(int i = 0; i < str.length(); i++){
            if(rev.charAt(i) == '0' && str.charAt(i) == '0'){
                ans += '0';
            }else if(rev.charAt(i) == '1' && str.charAt(i) == '1'){
                ans += '0';
            }else if(rev.charAt(i) == '0' && str.charAt(i) == '1'){
                ans += '1';
            }else if(rev.charAt(i) == '1' && str.charAt(i) == '0'){
                ans += '1';
            }
        }
        return ans;
    }
}
